package com.etc.service;

import java.text.ParseException;
import java.util.List;

import javax.annotation.Resource;

import com.etc.dao.SysLogMapper;
import com.etc.dao.SysOrderMapper;
import com.etc.entity.SysLog;
import com.etc.entity.SysOrder;
import com.etc.entity.SysOrderExample;
import com.etc.utils.DateTimeUtil;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;


/**
 * 记录日志
 * @author Administrator
 *
 */
@Service
@Slf4j
public class SysLogService {

	@Resource
	private SysOrderMapper sysOrderMapper;

	/**
	 * 获取今天订单
	 * @return
	 */
	public List<SysOrder> getOrder()throws ParseException{

		//开始时间
		String start = DateTimeUtil.getTodayStart();
		//结束时间
		String end = String.valueOf(System.currentTimeMillis());
		SysOrderExample sysOrderExample = new SysOrderExample();
		SysOrderExample.Criteria criteria = sysOrderExample.createCriteria();
		criteria.andOrderDateGreaterThanOrEqualTo(start).andOrderDateLessThanOrEqualTo(end);
		//获取今天的订单
		List<SysOrder> sysOrders = sysOrderMapper.selectByExample(sysOrderExample);
		return sysOrders;
	}


	/**
	 * 今天完成订单
	 * @return
	 */
	public List<SysOrder> finsh() throws ParseException {
//开始时间
		String start = DateTimeUtil.getTodayStart();
		//结束时间
		String end = String.valueOf(System.currentTimeMillis());
		SysOrderExample sysOrderExample = new SysOrderExample();
		SysOrderExample.Criteria criteria = sysOrderExample.createCriteria();
		criteria.andOrderDateGreaterThanOrEqualTo(start)
				.andOrderDateLessThanOrEqualTo(end)
		        .andStatusEqualTo("6");
		;
		//获取今天的订单
		List<SysOrder> sysOrders = sysOrderMapper.selectByExample(sysOrderExample);
		return sysOrders;
	}

	/**
	 * 本日未处理
	 * @return
	 */
	public List<SysOrder> getdfd() throws ParseException {
//开始时间
		String start = DateTimeUtil.getTodayStart();
		//结束时间
		String end = String.valueOf(System.currentTimeMillis());
		SysOrderExample sysOrderExample = new SysOrderExample();
		SysOrderExample.Criteria criteria = sysOrderExample.createCriteria();
		criteria.andOrderDateGreaterThanOrEqualTo(start)
				.andOrderDateLessThanOrEqualTo(end)
				.andStatusEqualTo("1");
		;
		//获取今天的订单
		List<SysOrder> sysOrders = sysOrderMapper.selectByExample(sysOrderExample);
		return sysOrders;
	}


	/**
	 * 营业额
	 * @return
	 * @throws ParseException
	 */
	public List<SysOrder> getTurnover() throws ParseException {

		SysOrderExample sysOrderExample = new SysOrderExample();
		sysOrderExample.setOrderByClause("order_date ASC");
		List<SysOrder> sysOrders = sysOrderMapper.selectByExample(sysOrderExample);
		return sysOrders;
	}
}
